﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using Infragistics.Windows.Ribbon;
using QLKS.SysLib;
using System.Data;

namespace QLKS.Templates
{
    public class FormRibbon: XamRibbonWindow
    {
         #region PROPERTY
        object parent;
        public string M_LAN = string.Empty;
        DataSet ds = new DataSet();
        #endregion
        //Khởi tạo mặc định
        #region KHỞI TẠO
        public FormRibbon()
            : base()
        {
            parent = this;
            M_LAN = LanguageLib.GetLanguage();
            this.PreviewKeyDown += new System.Windows.Input.KeyEventHandler(FormTrans_PreviewKeyDown);
            this.Loaded += new RoutedEventHandler(FormTrans_Loaded);
        }
        #endregion
        //Form Load
        #region FormLoad
        private void FormTrans_Loaded(object sender, RoutedEventArgs e)
        {
            this.Reload_Language();
        }
        #endregion
        //KeyDown{F3}
        #region KeyDown{F12}
        private void FormTrans_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.F12)
            {
                LanguageLib.ScanControl(this.Name, "", this);
                ds = SysObj.Preview_F12(this.Name);
                LanguageLib.LoadControl(ds.Tables[0],"",Application.Current.MainWindow, LanguageLib.GetLanguage());
            }
        }
        #endregion
        //Refresh Language
        #region Refresh Language
        public void Reload_Language()
        {
            M_LAN = LanguageLib.GetLanguage();
            string FileName = System.Windows.Forms.Application.StartupPath + "\\LANG\\" + this.Name + ".xml";
            if (!System.IO.File.Exists(FileName))
                return;
            ds.ReadXml(FileName);
            LanguageLib.LoadControl(ds.Tables[0],"",parent, M_LAN);
        }
        #endregion
        //Show ProgressBar for Waiting
        #region Show ProgressBar
        public void Waiting(long maxvalue, long value)
        {
            Waiting(maxvalue, value);
        }
        #endregion
    }
}
